home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / program / rcs5ap1s.lzh / RLOG.C < prev    next >
C/C++ Source or Header  |  1991-01-30  |  34KB  |  1,165 lines

  1. /*
  2.  *                       RLOG    operation
  3.  */
  4. /*****************************************************************************
  5.  *                       print contents of RCS files
  6.  *****************************************************************************
  7.  */
  8.  
  9. /* Copyright (C) 1982, 1988, 1989 Walter Tichy
  10.    Copyright 1990 by Paul Eggert
  11.    Distributed under license by the Free Software Foundation, Inc.
  12.  
  13. This file is part of RCS.
  14.  
  15. RCS is free software; you can redistribute it and/or modify
  16. it under the terms of the GNU General Public License as published by
  17. the Free Software Foundation; either version 1, or (at your option)
  18. any later version.
  19.  
  20. RCS is distributed in the hope that it will be useful,
  21. but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23. GNU General Public License for more details.
  24.  
  25. You should have received a copy of the GNU General Public License
  26. along with RCS; see the file COPYING.  If not, write to
  27. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  28.  
  29. Report problems and direct all questions to:
  30.  
  31.     rcs-bugs@cs.purdue.edu
  32.  
  33. */
  34.  
  35.  
  36.  
  37.  
  38. /* $Log: rlog.c,v $
  39.  * Revision 5.8  1991/01/30  14:21:32  apratt
  40.  * CI with RCS version 5
  41.  *
  42.  * Revision 5.7  91/01/30  12:02:48  apratt
  43.  * Changed RCS5AKP1 to RCS5AP1
  44.  * 
  45.  * Revision 5.6  91/01/29  17:45:26  apratt
  46.  * Added RCS5AKP1 to usage message
  47.  * 
  48.  * Revision 5.5  90/11/01  05:03:55  eggert
  49.  * checked in with -k by apratt at 91.01.10.13.15.34.
  50.  * 
  51.  * Revision 5.5  1990/11/01  05:03:55  eggert
  52.  * Permit arbitrary data in logs and comment leaders.
  53.  *
  54.  * Revision 5.4  1990/10/04  06:30:22  eggert
  55.  * Accumulate exit status across files.
  56.  *
  57.  * Revision 5.3  1990/09/11  02:41:16  eggert
  58.  * Plug memory leak.
  59.  *
  60.  * Revision 5.2  1990/09/04  08:02:33  eggert
  61.  * Count RCS lines better.
  62.  *
  63.  * Revision 5.0  1990/08/22  08:13:48  eggert
  64.  * Remove compile-time limits; use malloc instead.  Add setuid support.
  65.  * Switch to GMT.
  66.  * Report dates in long form, to warn about dates past 1999/12/31.
  67.  * Change "added/del" message to make room for the longer dates.
  68.  * Don't generate trailing white space.  Add -V.  Ansify and Posixate.
  69.  *
  70.  * Revision 4.7  89/05/01  15:13:48  narten
  71.  * changed copyright header to reflect current distribution rules
  72.  * 
  73.  * Revision 4.6  88/08/09  19:13:28  eggert
  74.  * Check for memory exhaustion; don't access freed storage.
  75.  * Shrink stdio code size; remove lint.
  76.  * 
  77.  * Revision 4.5  87/12/18  11:46:38  narten
  78.  * more lint cleanups (Guy Harris)
  79.  * 
  80.  * Revision 4.4  87/10/18  10:41:12  narten
  81.  * Updating version numbers
  82.  * Changes relative to 1.1 actually relative to 4.2
  83.  * 
  84.  * Revision 1.3  87/09/24  14:01:10  narten
  85.  * Sources now pass through lint (if you ignore printf/sprintf/fprintf 
  86.  * warnings)
  87.  * 
  88.  * Revision 1.2  87/03/27  14:22:45  jenkins
  89.  * Port to suns
  90.  * 
  91.  * Revision 4.2  83/12/05  09:18:09  wft
  92.  * changed rewriteflag to external.
  93.  * 
  94.  * Revision 4.1  83/05/11  16:16:55  wft
  95.  * Added -b, updated getnumericrev() accordingly.
  96.  * Replaced getpwuid() with getcaller().
  97.  * 
  98.  * Revision 3.7  83/05/11  14:24:13  wft
  99.  * Added options -L and -R;
  100.  * Fixed selection bug with -l on multiple files.
  101.  * Fixed error on dates of the form -d'>date' (rewrote getdatepair()).
  102.  * 
  103.  * Revision 3.6  82/12/24  15:57:53  wft
  104.  * shortened output format.
  105.  *
  106.  * Revision 3.5  82/12/08  21:45:26  wft
  107.  * removed call to checkaccesslist(); used DATEFORM to format all dates;
  108.  * removed unused variables.
  109.  *
  110.  * Revision 3.4  82/12/04  13:26:25  wft
  111.  * Replaced getdelta() with gettree(); removed updating of field lockedby.
  112.  *
  113.  * Revision 3.3  82/12/03  14:08:20  wft
  114.  * Replaced getlogin with getpwuid(), %02d with %.2d, fancydate with PRINTDATE.
  115.  * Fixed printing of nil, removed printing of Suffix,
  116.  * added shortcut if no revisions are printed, disambiguated struct members.
  117.  *
  118.  * Revision 3.2  82/10/18  21:09:06  wft
  119.  * call to curdir replaced with getfullRCSname(),
  120.  * fixed call to getlogin(), cosmetic changes on output,
  121.  * changed conflicting long identifiers.
  122.  *
  123.  * Revision 3.1  82/10/13  16:07:56  wft
  124.  * fixed type of variables receiving from getc() (char -> int).
  125.  */
  126.  
  127.  
  128.  
  129. #include "rcsbase.h"
  130.  
  131. struct  lockers {                     /* lockers in locker option; stored   */
  132.      const char         * login;      /* lockerlist                         */
  133.      struct     lockers * lockerlink;
  134.      }  ;
  135.  
  136. struct  stateattri {                  /* states in state option; stored in  */
  137.      const char         * status;     /* statelist                          */
  138.      struct  stateattri * nextstate;
  139.      }  ;
  140.  
  141. struct  authors {                     /* login names in author option;      */
  142.      const char         * login;      /* stored in authorlist               */
  143.      struct     authors * nextauthor;
  144.      }  ;
  145.  
  146. struct Revpairs{                      /* revision or branch range in -r     */
  147.      unsigned          numfld;     /* option; stored in revlist        */
  148.      const char         * strtrev;
  149.      const char         * endrev;
  150.      struct  Revpairs   * rnext;
  151.      } ;
  152.  
  153. struct Datepairs{                     /* date range in -d option; stored in */
  154.      char               strtdate[datesize];   /* duelst and datelist      */
  155.      char               enddate[datesize];
  156.      struct  Datepairs  * dnext;
  157.      };
  158.  
  159. static char extractdelta P((const struct hshentry*));
  160. static int checkrevpair P((const char*,const char*));
  161. static int readdeltalog P((void));
  162. static void cleanup P((void));
  163. static void extdate P((struct hshentry*));
  164. static void exttree P((struct hshentry*));
  165. static void getauthor P((char*));
  166. static void getdatepair P((char*));
  167. static void getlocker P((char*));
  168. static void getnumericrev P((void));
  169. static void getrevpairs P((char*));
  170. static void getscript P((struct hshentry*));
  171. static void getstate P((char*));
  172. static void putabranch P((const struct hshentry*));
  173. static void putadelta P((const struct hshentry*,const struct hshentry*,int));
  174. static void putforest P((const struct branchhead*));
  175. static void putree P((const struct hshentry*));
  176. static void putrunk P((void));
  177. static void recentdate P((const struct hshentry*,struct Datepairs*));
  178. static void trunclocks P((void));
  179.  
  180. static const char *insDelFormat;
  181. static int branchflag;    /*set on -b */
  182. static int exitstatus;
  183. static int lockflag;
  184. static int revno;    /* number of revision chosen */
  185. static struct Datepairs *datelist, *duelst;
  186. static struct Revpairs *revlist, *Revlst;
  187. static struct authors *authorlist;
  188. static struct lockers *lockerlist;
  189. static struct stateattri *statelist;
  190.  
  191.  
  192. mainProg(rlogId, "rlog", "$Id: rlog.c,v 5.8 1991/01/30 14:21:32 apratt Exp $")
  193. {
  194.     static const char cmdusage[] =
  195.         "\nRCS5AP1 as modified for TOS by Allan Pratt, atari!apratt\nrlog usage: rlog -{bhLRt} -ddates -l[lockers] -rrevs -sstates -w[logins] -Vn file ...";
  196.  
  197.     struct Datepairs *currdate;
  198.     const char *accessListString, *accessFormat, *commentFormat;
  199.     const char *headFormat, *symbolFormat;
  200.     const struct access *curaccess;
  201.     const struct assoc *curassoc;
  202.     const struct lock *currlock;
  203.     int descflag, selectflag;
  204.     int onlylockflag;  /* print only files with locks */
  205.     int selectop;  /* print only some revisions */
  206.     int onlyRCSflag;  /* print only RCS file name */
  207.  
  208.     initid();
  209.  
  210.         descflag = selectflag = true;
  211.     onlylockflag = selectop = onlyRCSflag = false;
  212.  
  213.         while (--argc,++argv, argc>=1 && ((*argv)[0] == '-')) {
  214.                 switch ((*argv)[1]) {
  215.  
  216.         case 'L':
  217.             onlylockflag = true;
  218.             break;
  219.  
  220.         case 'R':
  221.             onlyRCSflag =true;
  222.             break;
  223.  
  224.                 case 'l':
  225.                         selectop = true;
  226.                         lockflag = true;
  227.                         getlocker( (*argv)+2 );
  228.                         break;
  229.  
  230.                 case 'b':
  231.                         selectop = true;
  232.                         branchflag = true;
  233.                         break;
  234.  
  235.                 case 'r':
  236.                         selectop = true;
  237.                         getrevpairs( (*a